import React from 'react'
import { Redirect } from 'umi'
import useAuth from './useAuth'

function App (props: any) {
    const data = useAuth()
    if(data === 1) {
        return <div>正在加载</div>
    } else if (data === 2) {
        return <div>出错了</div>
    } else {
        if(data.data.length > 0) {
          if(data.data[0].role > 1) {
              return <div>{props.children}</div>
          } else {
              return <div>无权限</div>
          }
       } else {
           return <Redirect to="/login"/>
       } 
    }
}
export default App